﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Fruit.UI
{
    public partial class Fruit_Main : Form
    {
        public Fruit_Main()
        {
            InitializeComponent();
        }

        private void Fruit_Main_Load(object sender, EventArgs e)
        {
            tssCurrentUser.Text = "当前用户:老板";
            tssCurrentUser.TextAlign = ContentAlignment.MiddleLeft;
            tssUserType.Text = "用户类型:管理员";
            tssUserType.TextAlign = ContentAlignment.MiddleLeft;
            // 启动计时器
            timeCurrentTime.Start();
        }
        /// <summary>
        /// 显示实时时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timeCurrentTime_Tick(object sender, EventArgs e)
        {
            tssDatetime.Text = "当前时间:" + DateTime.Now.ToString("yyyy年MM月dd日  HH时mm分ss秒");
            tssDatetime.TextAlign = ContentAlignment.MiddleRight;
        }
        /// <summary>
        /// 菜单退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiExit_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("您确定要退出吗？", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                Application.Exit();
            }
        }
        /// <summary>
        /// 点击X退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Fruit_Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult result = MessageBox.Show("您确定要退出吗？", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                e.Cancel = false;
            }
            else
            {
                e.Cancel = true;
            }
        }
        /// <summary>
        /// 新增用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiAdd_Click(object sender, EventArgs e)
        {
            Fruit_UserInfo userinfo = new Fruit_UserInfo();
            userinfo.ShowDialog();
        }
    }
}
